package com.happy.zebra.admin.ui.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.happy.zebra.admin.ui.mapper.SmMemberOrderMapper;
import com.happy.zebra.admin.ui.service.SmMemberOrderService;
import com.shycloud.mido.common.core.exception.BusinessException;
import com.shycloud.mido.member.api.entity.MemberOrder;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class SmMemberOrderServiceImpl extends ServiceImpl<SmMemberOrderMapper, MemberOrder> implements SmMemberOrderService {

	private final SmMemberOrderMapper memberOrderMapper;

	@Override
	public Boolean updateOrder(MemberOrder memberOrder) {
		MemberOrder memberOrder1 = memberOrderMapper.selectById(memberOrder.getOrderNo());
		if ("4".equals(memberOrder.getStatus()) || "1".equals(memberOrder.getStatus())) {
			memberOrder1.setStatus(memberOrder.getStatus());
			return memberOrderMapper.updateById(memberOrder1) == 1;
		}
		throw new BusinessException("目前只支持更改【退款】【已支付】状态的订单");
	}

}
